package com.basic.spi;

import java.util.Iterator;
import java.util.ServiceLoader;

public class SPITest {

	public static void main(String[] args) {
		SPIService spiService = SPITest.instance();
		spiService.spi();
	}
	
	public static SPIService instance(){
		SPIService spiService = null;
		ServiceLoader<SPIService> serviceLoaders = ServiceLoader.load(SPIService.class);
		Iterator<SPIService> iterator = serviceLoaders.iterator();
		while (iterator.hasNext()) {
			spiService = iterator.next();
		}
		return spiService;
	}
}
